'use strict';
const {
  Model, INTEGER
} = require('sequelize');
const { Sequelize } = require('.');
const moment = require('moment')
const sequelize = require('sequelize')
module.exports = (sequelize, DataTypes) => {
  // class driver extends Model {
  //   /**
  //    * Helper method for defining associations.
  //    * This method is not a part of Sequelize lifecycle.
  //    * The `models/index` file will call this method automatically.
  //    */
  //   static associate(models) {
  //     // define association here
  //   }
  // };
  const der=sequelize.define('der',{
    DriverID:{
      allowNull: false,
      primaryKey: true,
      type: DataTypes.INTEGER,
      autoIncrement:true
    },
    DriverName:{
      allowNull: false,
      type: DataTypes.STRING
    },
    PhoneNum:{
      type:DataTypes.STRING,
      allowNull:false
    },
    FleetID:{
      type:DataTypes.INTEGER,
    },
    status:{
      type:DataTypes.INTEGER,
      allowNull:true
    },
    OpenID:{
      type:DataTypes.STRING
    },
    NickName:{
      type:DataTypes.STRING,
    },
    SubscribeStatus:{
      type:DataTypes.INTEGER,
      allowNull:true
    },
    CreateTime:{
      type:DataTypes.DATE()
    },
    LastLoginTime:{
      type:DataTypes.DATE()
    }
},{
  timestamps:false
});
der.associate=function(models){
  der.hasMany(models.driverTruck,{
    foreignKey:'DriverID',
    sourceKey:'DriverID'
  })
  // der.hasMany(models.receipt,{
  //   foreignKey:'PhoneNum',
  //   sourceKey:'PhoneNum'
  // })
}
  return der;
};